package com.org.daniel.project.controller.business;

import com.org.daniel.module.domain.ResultResponse;
import com.org.daniel.module.entity.master.UserInfo;
import com.org.daniel.service.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Daniel
 */
@Api(value = "test", tags = "test测试")
@RestController
@RequestMapping("test")
public class UserInfoController {

	@Autowired
	private UserInfoService userInfoService;

	@ApiOperation(value = "hello", notes = "hello测试")
	@RequestMapping(value = "hello", method = RequestMethod.GET)
	public ResultResponse hello(){
		return userInfoService.queryAllUserInfo();
	}

	@ApiOperation(value = "获取用户列表", notes = "根据页数获取用户列表")
	@RequestMapping(value = "page/list", method = RequestMethod.GET)
	public ResultResponse<List<UserInfo>> queryByPage(@RequestParam(value = "pageNum", required = true) int pageNum,
	                                                  @RequestParam(value = "pageSize", required = true) int pageSize){
		return userInfoService.queryUserInfoByPage(pageNum, pageSize);
	}

	@ApiOperation(value = "测试Redis", notes = "进行Redis测试")
	@RequestMapping(value = "redis", method = RequestMethod.GET)
	public ResultResponse testRedis(@RequestParam(value = "key") String key,
	                                @RequestParam(value = "value") String value){
		return userInfoService.testRedis(key, value);
	}

}
